<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>社医堂</title>
<link rel="stylesheet" type="text/css" href="../../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/hui.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/iconfont.css" />
</head>
<body>

	
<div class="hui-wrap">
		
	<div class="hui-center-title"><h1 style="width:100%;height:80px !important;line-height:24px;font-size:18px !important;padding-top:20px;"></h1></div>
    <div style="text-align:center;background-color:aliceblue;padding:8px;"><span id="time"></span><span id="hits" style="padding-left:30px;">1</span>次</div>
	<div class="hui-content" style="padding:18px 8px;line-height:36px;font-size:18px;" id="content">
			
	</div>

    <div style="margin-bottom:40px;;">
        <textarea id="replycontent" style="width:96%;margin-left:2%;height:100px;border:solid #ccc 1px;background-color:#fff;border-radius:5px;"></textarea>
        <span style="margin-left:2%;padding:6px;" id="loginstatus">请先登录</span>
        <button onclick="submitcommnet()" type="button" class="hui-button hui-button-large hui-primary" id="submit" style="width:50%;float:right;margin-right:2%">发布评论</button>
    </div>
	<style>
        .comment{width:96%;margin-left:2%;}
        .comment ul{padding:0px;border-bottom:solid #ccc 1px;margin-bottom:10px;;}
        .comment ul li{width:100%;text-align: left;padding:5px;line-height:28px;}
        .comment ul li span{float: right;padding-right:10px;}
        .comment ul .cont{color:#888;}
    </style>
    <div class="comment"></div>

    <br />
    <br />
</div>


<script src="../../../script/hui.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../script/hui-tab.js" type="text/javascript"></script>
<script src="../../../script/api.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../script/stm.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
apiready = function () {


	islogin(1)

	api.ajax({
        url  : $api.getStorage('geturl')+'&c=ajaxmember&a=newsdetails',
        method: 'post',
        data: {
            values: { 
                id : api.pageParam.id,
            }
        }
    },function(res, err){

        if (res) {			
            if (res.status==1) {

				hui(".hui-center-title h1").html(res.data.title)
                hui("#time").html(res.data.addtime)
                hui("#hits").html(res.data.hits)
				hui("#content").html(res.data.content)
				
            }else{
                api.toast({ msg:res.tip,location:'top' })
            }
        } else {
            alert( JSON.stringify( err ) );
        }
    });

    getcomment()
    


	

}

function getcomment(contentid){

    if(contentid == ''){
        contentid = api.pageParam.id
    }

    api.ajax({
        url  : $api.getStorage('geturl')+'&c=ajaxmember&a=newscomment',
        method: 'post',
        data: {
            values: { 
                id : api.pageParam.id,
            }
        }
        },function(res, err){

        if (res) {			
            if (res.status==1) {

                var list = ''
                for(i=0;i<res.data.length;i++){
                    list += '<ul><li>'+res.data[i].username+'<span>'+jsDateDiff(res.data[i].addtime,0)+'</span></li><li class="cont">'+res.data[i].content+'</li></ul>';			
                }
                hui(".comment").html(list)

            }else{
                api.toast({ msg:res.tip,location:'top' })
            }
        } else {
            alert( JSON.stringify( err ) );
        }

    }); 
}


function submitcommnet(){

    contentid = api.pageParam.id
    api.ajax({
        url: $api.getStorage('geturl')+'&c=ajaxmember&a=submitcomment',
        method: 'post',
        data: {
            values: { 
                userid    : $api.getStorage('userid'),
                username  : $api.getStorage('username'),                
                contentid : contentid,
                content   : hui("#replycontent").val(),
            }
        }
    },function(ret, err){
        if (ret) {
            hui("#replycontent").val('');
            hui.iconToast(ret.tip, 'success');
            getcomment(contentid);
        } else {
            alert( JSON.stringify( err ) );
        }

    });

}

</script>

</body>
</html>